Skip to main content

All Questions

1vote
2answers
312views

Remove exact line from file if present, leave the rest of lines; error-handling - how to go about it

I am not exactly sure how text processing should be done in a good way, so let me ask. I have this file: ~/.config/mpv/input.conf containing possibly other options as well as v disable. If I want to ...
Vlastimil Burián's user avatar
2votes
4answers
700views

Count lines ending in "*"

I have several files in a directory with this kind of content: Wood * Nails Large Hammer * Some names have a star after them, some don't. I have multiple files with such content. In each file a ...
math101's user avatar
10votes
7answers
4kviews

How to grep everything BUT the match AND the previous line

I have a text file, and I have a pattern that I want grep not to match. Thing is, I also want the line before not to match. My file: line 1 line 2 pattern line 4 And I tried cat file | grep -v ...
Peter Petigru's user avatar
0votes
1answer
221views

Read subdirectory names and split into subdirectories based on dir name

This is probably really simple but I'm ox-hilling it for the better part of the day. Problem: I have several folders coming out of an app that I need to get into sub-folders. I'm going with separators ...
Voodoopants's user avatar
1vote
2answers
324views

Extract field and number of occurrences per line

I have this file: John Green', 'Age: 32', 'State: New York', 'Total cars: 2', 'Manufacter: General Motor', 'Model: Pontiac', 'Year: 2000', 'Manufacter: Ford Motor', 'Model: Endeavour', 'Year: 2010 ...
Emilio Galarraga's user avatar
0votes
1answer
597views

grep -v not working inside shell script

I have this line inside my shell script: tomcatPID=$(ps -ef | grep tomcat | grep $TOMCAT_ACCOUNT | grep -v grep | grep -v restart | awk '{print $2}') I made sure that the $TOMCAT_ACCOUNT part is okay....
Lipaw11's user avatar
-3votes
4answers
351views

Bash Script help- Text Parsing & Output

I am having text file of the following type, a b c d -- -- -- -- 1 ok device issue Some Action which has to be taken which ...
Ramana's user avatar
-1votes
3answers
864views

Extract content of a specific column with awk/sed [closed]

Provided file: $ cat CronConfig `FILE SYSTEM` `------------` warningThreshold: 77 criticalThreshold: 99 `MEMORY` `-------` warningThreshold: 66 criticalThreshold: 88 `CPU` `----` ...
Dibya prakash's user avatar
0votes
1answer
51views

Read a file and search for 1st occurrence of specific string and matches certain patterns only

This question is a continuation of a question I have asked earlier Sample data file: empid;A1001 empname;ABC salary;3000 dept;ABC age;24 dept;112 JOD;20170101 empid;#201 empid;A2001 salary;5000 ...
Naresh's user avatar
2votes
2answers
633views

Is there any use case for `sed -n "/regexp/p"` in a world where grep exists?

sed -n "/regexp/p" will print only lines that match regexp and no other. This seems exactly equivalent to what grep does. The only use case I see to use this construct instead of grep is if you're ...
Mobus Dorphin's user avatar
0votes
2answers
283views

Filter a file, multiply a value in the lines that contain certain string, return all lines

With grep filter a file, from that filtered lines do a math operation on a specific column, only in the lines that contains a string "value=", return all the lines from the first grep filter ...
Tapioca's user avatar
5votes
3answers
2kviews

pruning subdomains of other domains in a file using script (bash, awk or similar)

I have a huge size file (ten thousand entries) comprising of domains (in random order, but no duplicate domains and with an arbitrary number of subdomains), here is a little example: domain.com ...
Fabio's user avatar
3votes
3answers
2kviews

Grep complete name including dot in the word

In a ksh shell script I am using a grep command to get a specific word as shown below. $ cat file.txt abc xyzdef.123 def.jkl mnopqrst $ grep -o "\wdef\w" file.txt xyzdef def I want output to be ...
Arnav's user avatar
0votes
1answer
921views

Insert characters at the middle and the end of a line with specific line length

Currently I am working on a folder of files, and each file have some lines as follows: abcde fghij abcde fghij jklmn pqrst ..... ..... These lines have a specific line length 43. At the ...
Frown's user avatar
1vote
1answer
369views

for loops to grep multiple texts from parent file to multiple files in single command

I have 29 fasta files (.fa as extension) named and stored sequences according to their genes. (Example: ribosomal protein L1, ribosomal protein L6P/L9E,...) There were a total of 722 species ...
web's user avatar
  • 193

153050per page
close